/*
 *  Netzpult - Your desk on the web
 *  Copyright (C) 2011  Ulrich Hilger, http://uhilger.de
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see http://www.gnu.org/licenses/
 */

package de.uhilger.netzpult.shared;

import java.io.Serializable;

import de.uhilger.baselink.DBColumn;
import de.uhilger.baselink.DBPrimaryKey;
import de.uhilger.baselink.DBTable;

/**
 * 
 * @author Copyright (c) Ulrich Hilger, http://uhilger.de
 * @author Published under the terms and conditions of
 * the <a href="http://www.gnu.org/licenses/" target="_blank">GNU General Public License</a>
 */
@DBTable(name = "webfiles.folders")
@DBPrimaryKey("fo_id")
public class Folder implements Serializable {
	
	private static final long serialVersionUID = -5405633351722119008L;

	public static final int NOT_FILED_FOLDER_ID = 1;
	public static final int PUBLIC_FOLDER_ID = 2;
	public static final int DRAFT_FOLDER_ID = 3;
	public static final int SHARED_FOLDER_ID = 4;
	public static final int ROOT_FOLDER_ID = 0;
	public static final int NEW_FOLDER_ID = -1;
	public static final String NEW_FOLDER_NAME = "Neuer Ordner";
	public static final String NOT_FILED_FOLDER_NAME = "nicht abgelegt";
	public static final String PUBLIC_FOLDER_NAME = "&Ouml;ffentlich";
	public static final String DRAFT_FOLDER_NAME = "Entw&uuml;rfe";
	public static final String SHARED_FOLDER_NAME = "f&uuml;r mich freigegeben";	

	private int id = NEW_FOLDER_ID;
	private int parentId = ROOT_FOLDER_ID;
	private String name = NEW_FOLDER_NAME;
	private int order;
	
	private static Folder notFiledFolder;
	private static Folder publicFolder;
	private static Folder draftFolder;
	private static Folder sharedFolder;
		
	public Folder() {
		super();
	}
	
	public Folder(int id) {
		this();
		this.id = id;
	}
	
	@DBColumn(name = "fo_order")
	public int getOrder() {
		return order;
	}

	public void setOrder(int order) {
		this.order = order;
	}

	public static Folder getNotFiledFolder() {
		if(notFiledFolder == null) {
			notFiledFolder = new Folder();
			notFiledFolder.setId(NOT_FILED_FOLDER_ID);
			notFiledFolder.setName(NOT_FILED_FOLDER_NAME);
			notFiledFolder.setParentId(ROOT_FOLDER_ID);
		}
		return notFiledFolder;
	}
	
	public static Folder getSharedFolder() {
		if(sharedFolder == null) {
			sharedFolder = new Folder();
			sharedFolder.setId(SHARED_FOLDER_ID);
			sharedFolder.setName(SHARED_FOLDER_NAME);
			sharedFolder.setParentId(ROOT_FOLDER_ID);
		}
		return sharedFolder;
	}
	
	public static Folder getPublicFolder() {
		if(publicFolder == null) {
			publicFolder = new Folder();
			publicFolder.setId(PUBLIC_FOLDER_ID);
			publicFolder.setName(PUBLIC_FOLDER_NAME);
			publicFolder.setParentId(ROOT_FOLDER_ID);
		}
		return publicFolder;
	}
	
	public static Folder getDraftFolder() {
		if(draftFolder == null) {
			draftFolder = new Folder();
			draftFolder.setId(DRAFT_FOLDER_ID);
			draftFolder.setName(DRAFT_FOLDER_NAME);
			draftFolder.setParentId(ROOT_FOLDER_ID);
		}
		return draftFolder;
	}
	
	@DBColumn(name = "fo_id")
	public int getId() {
		return id;
	}


	public void setId(int id) {
		this.id = id;
	}

	@DBColumn(name = "fo_parent")
	public int getParentId() {
		return parentId;
	}


	public void setParentId(int parentId) {
		this.parentId = parentId;
	}


	@DBColumn(name = "fo_name")
	public String getName() {
		return name;
	}


	public void setName(String name) {
		this.name = name;
	}
	
	
}
